﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Web;
using System.Web.Caching;
using WeFrame.Core.Common;
using WeFrame.Core.Model;
using WeFrame.Core.DAL;

namespace WeFrame.Core.BLL
{
    public partial class SiteConfigBLL
    {
        private readonly SiteConfigDAL dal = new SiteConfigDAL();

        /// <summary>
        ///  读取配置文件
        /// </summary>
        public SiteConfigModel loadConfig()
        {
            SiteConfigModel model = CacheHelper.Get<SiteConfigModel>(WeFrameKey.CACHE_SITE_CONFIG);
            if (model == null)
            {
                CacheHelper.Insert(WeFrameKey.CACHE_SITE_CONFIG, dal.loadConfig(Utils.GetXmlMapPath(WeFrameKey.FILE_SITE_XML_CONFING)),
                    Utils.GetXmlMapPath(WeFrameKey.FILE_SITE_XML_CONFING));
                model = CacheHelper.Get<SiteConfigModel>(WeFrameKey.CACHE_SITE_CONFIG);
            }
            return model;
        }

        /// <summary>
        ///  保存配置文件
        /// </summary>
        public SiteConfigModel saveConifg(SiteConfigModel model)
        {
            return dal.saveConifg(model, Utils.GetXmlMapPath(WeFrameKey.FILE_SITE_XML_CONFING));
        }

    }
}
